/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.hva.web.mvcwebapp.models;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "widget")
public class Widget implements java.io.Serializable {

    private Integer widgetId;
    private String widgetName;
    private String widgetPath;
    private Set<PageWidget> pageWidget = new HashSet<PageWidget>(0);

    public Widget() {
    }

    public Widget(String name, String path) {
        this.widgetName = name;
        this.widgetPath = path;
    }

    public Widget(String name, String path, Set<PageWidget> pageWidget) {
        this.widgetName = name;
        this.widgetPath = path;
        this.pageWidget = pageWidget;
    }

    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "WIDGET_ID", unique = true, nullable = false)
    public Integer getWidgetId() {
        return this.widgetId;
    }

    public void setWidgetId(Integer widgetId) {
        this.widgetId = widgetId;
    }

    @Column(name = "WIDGET_NAME", nullable = false, length = 20)
    public String getName() {
        return this.widgetName;
    }

    public void setName(String name) {
        this.widgetName = name;
    }

    @Column(name = "WIDGET_PATH", nullable = false)
    public String getWidgetPath() {
        return this.widgetPath;
    }

    public void setWidgetPath(String widgetPath) {
        this.widgetPath = widgetPath;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "pk.widget", cascade=CascadeType.ALL)
    public Set<PageWidget> getPageWidget() {
        return this.pageWidget;
    }

    public void setPageWidget(Set<PageWidget> pageWidget) {
        this.pageWidget = pageWidget;
    }
}